<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>咨询记录列表</title>
    <?php PrintPageHead(); ?>
    <link href="../resource/css/hermes.css" rel="stylesheet">
    <link href="../resource/js/calendar/calendar-blue.css" type="text/css" rel="stylesheet">
    <script src="../resource/js/calendar/calendar.js" type="text/javascript"></script>
    <script src="../resource/js/hermes.js"></script>
    <?php
    if (!array_key_exists("公众号ID",$_SESSION)) {
        header("Location:back.php");
    }
    pdo()->beginTransaction();
    $bm=new C后台管理员();
    $添加咨询 = 'back.php?state=back13Add_ZiXun';
    $查看图文 = 'back.php?state=back13Add_MuBan';
    $模板消息=$bm->Get模板消息($_GET['page'],$_GET);

    ?>
</head>
<body>


<div class="container-fluid">
    <?php include_once 'back_header.php'; ?>
    <div class="panel panel-primary">
        <div class="panel-heading text-center"><h3 class="panel-title">咨询记录列表</h3></div>
        <div class="panel-body" style="text-align:center">
            <div class="panel-heading text-right"><a href="<?=$添加咨询?>" type="button" class="btn btn-primary">添加模板资讯</a></div>
            <div class="panel-heading text-right">
                   测试openID: <input type="text" id="oid">
            </div>
            <div class="panel-group"  id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="row" >
                            <div class="col-xs-1 col-sm-1">
                                排序
                            </div>
                            <div class="col-xs-3 col-sm-3">
                                标题
                            </div>
                            <div class="col-xs-1 col-sm-1">
                                发布人
                            </div>
                            <div class="col-xs-2 col-sm-2">
                                发布时间
                            </div>
                            <div class="col-xs-1 col-sm-1">
                                是否发送
                            </div>
                            <div class="col-xs-1 col-sm-1">
                                添加时间
                            </div>
                            <div class="col-xs-3 col-sm-3" style="text-align:center">
                                操作
                            </div>
                        </div>
                    </div>
                </div>
                <?php $i=1; foreach($模板消息['result'] as $v){?>
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <div class="row" >
                                <div class="col-xs-1 col-sm-1">
                                    <?=$i;?>&nbsp;
                                </div>
                                <div class="col-xs-3 col-sm-3">
                                    <?=$v['标题']?>&nbsp;
                                </div>
                                <div class="col-xs-1 col-sm-1">
                                    <?=$v['发布人']?>&nbsp;
                                </div>
                                <div class="col-xs-2 col-sm-2">
                                    <?=$v['发布时间']?>&nbsp;
                                </div>
                                <div class="col-xs-1 col-sm-1">
                                    <?=$v['发送']?>&nbsp;
                                </div>
                                <div class="col-xs-1 col-sm-1">
                                    <?=$v['添加时间']?>
                                </div>
                                <div class="col-xs-3 col-sm-3" style="text-align:center">
                                    <button onclick="ceshi('<?=$v['id']?>')" class="btn btn-primary btn-xs">测试</button>
                                    <a href="<?=$添加咨询?>&id=<?=$v['id']?>"class="btn btn-primary btn-xs">编辑</a>
                                    <a href="<?=$查看图文?>&id=<?=$v['id']?>" class="btn btn-primary btn-xs">查看图文</a>

                                    <button onclick="disabled=true;tuisong('<?=$v['id']?>')" class="btn btn-primary btn-xs">推送</button>
                                    <button onclick="disabled=true;tuisong2('<?=$v['id']?>')" class="btn btn-primary btn-xs">未成功重发</button>
                                </div>

                            </div>
                        </div>
                    </div>
                <?php  $i++;}?>
            </div>
            <?=$模板消息['show']?>
        </div>

    </div>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="../resource/js/jquery-1.11.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../resource/js/bootstrap.min.js"></script>
<script language="JavaScript">
    function ceshi(id){
        var oid=$("#oid").val();
        if(oid){
            $.post('BackSellerAjax.php',{'id':id,'oid':oid,'businessFlag':'推送咨询'},function(data){
alert(data);
                alert("测试通过");
                location.reload();
            });
        }else{
            alert('请填写oid');
        }

    }

    function tuisong(id){
        var res = confirm('您真的确定吗?');
        if(res)
        {
            var oid=null;
            $.post('BackSellerAjax.php',{'id':id,'oid':'','businessFlag':'推送咨询'},function(data){

                alert("推送成功");
                location.reload();
            });
        }

    }
    function tuisong2(id){
        var res = confirm('您真的确定吗?');
        if(res)
        {
            var oid=null;
            $.post('BackSellerAjax.php',{'id':id,'businessFlag':'推送未成功咨询'},function(data){

                alert("推送成功");
                location.reload();
            });
        }
    }
</script>
</body>
</html>